package uml.behavioral.state.forum;

/**
 * 状态模式--具体状态类<br>
 * on 2023/1/6 14:33
 */
public class SeniorState extends UserState {
    public SeniorState(ForumUser user) {
        super(user);
    }

    public SeniorState(UserState state) {
        super(state);
    }

    @Override
    public void commit(String msg) {
        System.out.println(user.getUserName() + "发表品论[高级]" + msg);
        user.setIntegration(user.getIntegration() + commitForum);
        System.out.println("赚取积分：" + commitForum);
        stateSwitch();
    }

    @Override
    public void reply(String msg) {
        System.out.println(user.getUserName() + "回复品论[高级]" + msg);
        user.setIntegration(user.getIntegration() + replyForum * 2);
        System.out.println("赚取积分：" + commitForum * 2);
        stateSwitch();
    }

    @Override
    public void fileDownload(String fileName) {
        System.out.println(user.getUserName() + "下载文件[高级]：" + fileName);
        user.setIntegration(user.getIntegration() + downloadForum);
        System.out.println("扣除积分：" + -downloadForum);
        stateSwitch();
    }

    @Override
    protected void stateSwitch() {
        if (user.getIntegration() < 100) {
            user.setState(new PrimaryState(this));
        } else if (user.getIntegration() > 1000) {
            user.setState(new ProfessionalState(this));
        } else {
            if (!user.isClosed())
                System.out.println("系统消息：您为论坛高级用户,回复评论可获取双倍积分,可下载文件");
        }
    }
}
